<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" type="text/css"
	href="../EXT4/resources/css/ext-all.css" />
<link rel="stylesheet" type="text/css"
	href="../css/style.css" />
<script type="text/javascript" src="../EXT4/ext-all.js"></script>
<script type="text/javascript" src="../script/ext-lang-zh_CN.js"></script>
<script type="text/javascript">

Ext.onReady(function() {
	
	var itemsPerPage = 20;
	//定义model 
    Ext.define('Class', { 
        extend: 'Ext.data.Model', 
        // fields定义字段和数据类型 
        fields: ['id', 'className', 'bishopName','assistantName','count','age'] 
    });
	
    Ext.define('Student', { 
        extend: 'Ext.data.Model', 
        fields: ['id','studentName','w1','w2','w3','w4','w5','w6','w7','w8','w9','w10','w11','w12'] 
    });
	
    Ext.define('Worktime',{
    	extend: 'Ext.data.Model',
    	fields: ['id','worktime']
    });
    
    var classstore = Ext.create('Ext.data.Store', {
        model: 'Class', 
        autoLoad: true,
        pageSize: itemsPerPage,
        //使用ajax代理 
        proxy: { 
            type: 'ajax', 
            url: '../service/class1_findbyuser',
            //Reader 解码json数据 
            reader: { 
                type: 'json', 
                root: 'root', 
                total: 'total'
            }
        }
    });
    
	var select_store = Ext.create('Ext.data.Store', {
		model: 'Student', 
        pageSize: 10,
        proxy: { 
            type: 'ajax', 
            url: '../service/graduation_findSign',
            reader: { 
                type: 'json', 
                root: 'root'
            }
        }
	});
    
    //定义数据集 
    var store = Ext.create('Ext.data.Store', {
        model: 'Class', 
        autoLoad: true,
        //使用ajax代理 
        proxy: { 
            type: 'ajax', 
            url: '../service/class1_all',
            //Reader 解码json数据 
            reader: { 
                type: 'json', 
                root: 'root', 
                total: 'total'
            }
        }
    });
    
    var worktimestore = Ext.create('Ext.data.Store', {
    	model: 'Worktime', 
        pageSize: itemsPerPage,
        //使用ajax代理 
        proxy: { 
            type: 'ajax', 
            url: '../service/class1_findworktime',
            //Reader 解码json数据 
            reader: { 
                type: 'json', 
                root: 'worktimes'
            }
        }
    });
    
    var panel=Ext.create('Ext.Panel', {
        id:'main-panel',
        baseCls:'x-plain',
        renderTo:'sysusermng',
        items:[{
            xtype:'fieldset',
            title: '查询条件',
            collapsible: true,
            defaultType: 'textfield',
            layout: 'hbox',
            items :[Ext.create('Ext.form.field.ComboBox', {
        	    displayField: 'className',
        	    store: classstore,
        	    fieldLabel:'选择班级',
        	    valueField: 'id',
        	    labelWidth:60,
                width:200,
                margin:'0 10 0 0',
        	    id: 'searchclass',
                allowBlank: false,
        	    listeners: {
        	    	select: function(comb, records) {
        	    		Ext.each(records, function(record) {
        	    			worktimestore.load({
                    			params: {
                    		        id: record.data.id
                    		    },
                    		});
                		    Ext.getCmp('searchworktime').setDisabled(false);
                		    Ext.getCmp('searchworktime').setValue();
                		    select_store.removeAll();
        	    		});
        	    	}
        	    }
        	}),Ext.create('Ext.form.field.ComboBox', {
        	    displayField: 'worktime',
        	    store: worktimestore,
        	    fieldLabel:'上课时间',
        	    valueField: 'id',
                queryMode: 'local',
	        	disabled: true,
                labelWidth:60,
                width:200,
                margin:'0 10 0 0',
        	    id: 'searchworktime',
                allowBlank: false,
        	    listeners: {
        	    	select: function(comb, records) {
        	    		Ext.each(records, function(record) {
        	    			select_store.load({
                    			params:{
                    				classid: Ext.getCmp('searchclass').getValue(),
                    				worktime: record.data.id
                    			}
                    		});
        	    		});
        	    	}
        	    }
        	})]
        },Ext.create('Ext.grid.Panel', {
        	height:400,
        	store: select_store,
            columns: [ 
            { 
                text: '学生姓名', width: 100, sortable: true, dataIndex: 'studentName', editor: 'textfield'
            }, 
            { 
                text: 'W1', width: 80, dataIndex: 'w1', editor: 'textfield',
                renderer: function(value,metaData,record){
                	return	value==1?'√':'×';
                }
            },{ 
                text: 'W2', width: 80, dataIndex: 'w2', editor: 'textfield' ,
                renderer: function(value,metaData,record){
                	return	value==1?'√':'×';
                }
            },{ 
                text: 'W3', width: 80, dataIndex: 'w3', editor: 'textfield' ,
                renderer: function(value,metaData,record){
                	return	value==1?'√':'×';
                }
            },{ 
                text: 'W4', width: 80, dataIndex: 'w4', editor: 'textfield' ,
                renderer: function(value,metaData,record){
                	return	value==1?'√':'×';
                }
            },{ 
                text: 'W5', width: 80, dataIndex: 'w5', editor: 'textfield' ,
                renderer: function(value,metaData,record){
                	return	value==1?'√':'×';
                }
            },{ 
                text: 'W6', width: 80, dataIndex: 'w6', editor: 'textfield' ,
                renderer: function(value,metaData,record){
                	return	value==1?'√':'×';
                }
            },{ 
                text: 'W7', width: 80, dataIndex: 'w7', editor: 'textfield' ,
                renderer: function(value,metaData,record){
                	return	value==1?'√':'×';
                }
            },{ 
                text: 'W8', width: 80, dataIndex: 'w8', editor: 'textfield' ,
                renderer: function(value,metaData,record){
                	return	value==1?'√':'×';
                }
            },{ 
                text: 'W9', width: 80, dataIndex: 'w9', editor: 'textfield' ,
                renderer: function(value,metaData,record){
                	return	value==1?'√':'×';
                }
            },{ 
                text: 'W10', width: 80, dataIndex: 'w10', editor: 'textfield' ,
                renderer: function(value,metaData,record){
                	return	value==1?'√':'×';
                }
            },{ 
                text: 'W11', width: 80, dataIndex: 'w11', editor: 'textfield' ,
                renderer: function(value,metaData,record){
                	return	value==1?'√':'×';
                }
            },{ 
                text: 'W12', width: 80, dataIndex: 'w12', editor: 'textfield' ,
                renderer: function(value,metaData,record){
                	return	value==1?'√':'×';
                }
            }],
            tbar : [{  
                xtype : 'button',  
                text : '打印',
                handler: function() {
                	Ext.Ajax.request({
	        		    url: '../service/graduation_endClassContract',
	        		    params: {
	        		        classid: Ext.getCmp('searchclass').getValue(),
	        		    },
	        		    success: function(response, opts) {
	        		    	window.open('print?classid='+Ext.getCmp('searchclass').getValue()+'&worktime='+Ext.getCmp('searchworktime').getValue(), '', '');
	        		    },
	        		});
                	
                }
            }]
        })]
    });
    
    window.onresize = function(){
    	setTimeout(function(){panel.setWidth(Ext.getDom("sysusermng").width);},100);
	};
	
});
</script>
</head>
<body>
<div id="sysusermng"></div>
</body>
</html>